Is there a better way to write out long JavaScript if blocks